/*
*
==============================================================================
*  Name        : 
*  Part of     : Omen Game Engine - DirectX 10 Plugin
*  Description : 
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#define DIRECTX_10_PLUGIN_SOURCE 1

#include "DirectX_10_Texture.h"

using namespace Omen;

#include <string>
#include <algorithm>

DirectX_10_Texture::DirectX_10_Texture( const std::wstring& filename ) :
    m_fileName(filename)
{
    m_pTexture = 0;
}


DirectX_10_Texture::DirectX_10_Texture(const DirectX_10_Texture& other)
{
}


DirectX_10_Texture::~DirectX_10_Texture()
{
}


bool DirectX_10_Texture::Initialize(ID3D10Device* device)
{
    if( !m_pTexture )
    {
        HRESULT result;

        // Load the texture in.
        result = D3DX10CreateShaderResourceViewFromFile(device, m_fileName.c_str(), NULL, NULL, &m_pTexture, NULL);
        if(FAILED(result))
        {
            return false;
        }
    }

    return true;
}


void DirectX_10_Texture::Shutdown()
{
    // Release the texture resource.
    if(m_pTexture)
    {
        m_pTexture->Release();
        m_pTexture = 0;
    }

    return;
}


ID3D10ShaderResourceView* DirectX_10_Texture::GetTexture()
{
    return m_pTexture;
}